package com.jinghong.epidemiccontrolproject.mapper;


import com.jinghong.epidemiccontrolproject.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * ClassName:UserMapper
 * Package:com.jingjian.gamesetupapp.mapper
 * Description:
 *
 * @Author: 寻月君子
 * @CreatTime:2023/12/18 20:10
 * Version:1.0
 */
@Mapper
public interface UserMapper {
    //根据用户名查询用户
    @Select("select * from user where username=#{username}")
    User findByUserName(String username);


    //添加用户
    @Insert("insert into user(username,password,creat_time,update_time)" +
            " values(#{username},#{password},now(),now())")
    void add(String username, String password);


    /**
     * 用户信息查询
     * @return
     */
     List<User> list(String username);


    /**
     * 批量删除
     * @param ids
     */
    void delete(List<Integer> ids);




    /**
     * 根据ID更新用户
     * @param user
     * @return
     */
    void update(User user);


    /**
     * 根据ID查询用户
     * @param id
     * @return
     */
    @Select("select * from user where  id = #{id}")
    User getById(Integer id);


    /**
     * 根据名字和密码查询用户
     * @param user
     * @return
     */
    @Select("select * from user where username = #{username} and password = #{password}")
    User getByUsernameAndPassword(User user);


}
